/*
 * @file gkt_window_voice.h
 */

#ifndef GKT_WINDOW_VOICE_H
#define GKT_WINDOW_VOICE_H

#include "gkt_voice.h"
#include "gkt_language.h"

#ifdef __cplusplus
extern "C" {
#endif

enum {
	GKT_WINDOW_VOICE_EVENT_PLAY_START = 0,
	GKT_WINDOW_VOICE_EVENT_PLAY_END,
	GKT_WINDOW_VOICE_EVENT_PLAY_ERROR,
	GKT_WINDOW_VOICE_EVENT_PLAY_TIMEOUT,
	GKT_WINDOW_VOICE_EVENT_MAX
};

/*
 * window voice flags:
 * bit 0 ~ 15  : common flags
 * bit 16 ~ 23 : widget id
 * bit 24 ~ 31 : unused / inner used
 */
#define GKT_WINDOW_VOICE_F_COMMON_SHIFT	0
#define GKT_WINDOW_VOICE_F_UNINTERRUPT	(1U << 0)
#define GKT_WINDOW_VOICE_F_DETACHED	(1U << 1)
#define GKT_WINDOW_VOICE_F_RESIDENT	(1U << 2)
#define GKT_WINDOW_VOICE_F_FOLLOWING	(1U << 4)
#define GKT_WINDOW_VOICE_F_AUTO_RESTART	(1U << 5)
#define GKT_WINDOW_VOICE_F_MUTE_AFFECTED	(1U << 6)
#define GKT_WINDOW_VOICE_F_MULTIPLE_INDEX	(1U << 8)	/* multiple */
#define GKT_WINDOW_VOICE_F_HEAD_INDEX	(1U << 9)
#define GKT_WINDOW_VOICE_F_TAIL_PPI		(1U << 10)
#define GKT_WINDOW_VOICE_F_REPEAT_LISTEN	(1U << 11)
#define GKT_WINDOW_VOICE_F_NOTIFY_START	(1U << 12)
#define GKT_WINDOW_VOICE_F_NOTIFY_END	(1U << 13)
#define GKT_WINDOW_VOICE_F_NOTIFY_ERROR	(1U << 14)

#define GKT_WINDOW_VOICE_F_WIDGET_ID_SHIFT	16
#define GKT_WINDOW_VOICE_F_WIDGET_ID_BITS	7
#define GKT_WINDOW_VOICE_F_WIDGET_SHIFT	\
	(GKT_WINDOW_VOICE_F_WIDGET_ID_SHIFT + GKT_WINDOW_VOICE_F_WIDGET_ID_BITS)
#define GKT_WINDOW_VOICE_F_WIDGET	\
	(1U << GKT_WINDOW_VOICE_F_WIDGET_SHIFT)

#define GKT_WINDOW_VOICE_F_INNER_SHIFT	\
	(GKT_WINDOW_VOICE_F_WIDGET_SHIFT + 1)

enum {
	GKT_WINDOW_VOICE_COMMON_OPERATION_FORBID,
	GKT_WINDOW_VOICE_COMMON_MAX
};

#if !defined(GKT_CONFIG_WINDOW_VOICE_REPEAT_LISTEN) \
	|| GKT_CONFIG_WINDOW_VOICE_REPEAT_LISTEN
#define GKT_WINDOW_VOICE_REPEAT_LISTEN	1
#else
#define GKT_WINDOW_VOICE_REPEAT_LISTEN	0
#endif

enum {
	GKT_WINDOW_VOICE_INDEX_HINT_META_ID_0 = 0,
	/* 1 ~ 8 */
	GKT_WINDOW_VOICE_INDEX_HINT_META_ID_9 = 9,
#if GKT_WINDOW_VOICE_REPEAT_LISTEN
	GKT_WINDOW_VOICE_INDEX_HINT_META_ID_REPEAT_LISTEN,
#endif
	GKT_WINDOW_VOICE_INDEX_HINT_META_ID_MAX
};

typedef struct {
	uint32_t	combined_nums;
	const gkt_voice_combined_attr_s	*attrs_table;
	uint32_t	common_combined_ids[GKT_WINDOW_VOICE_COMMON_MAX];
	gkt_voice_meta_id_t	index_hint_meta_ids[GKT_WINDOW_VOICE_INDEX_HINT_META_ID_MAX];
} gkt_window_voice_config_params_s;

enum {
	GKT_WINDOW_VOICE_ST_PLAYING = GKT_SUCCESS,
	GKT_WINDOW_VOICE_ST_PENDING,
	GKT_WINDOW_VOICE_ST_MAX
};

#if GKT_CONFIG_VOICE_OUTPUT_ENABLE

void gkt_window_voice_config(gkt_language_e language,
			gkt_window_voice_config_params_s *config_params);

uint32_t gkt_window_voice_get_duration_ms(uint32_t combined_id,
			const gkt_voice_output_playback_attr_s *playback_attr);

int gkt_window_voice_play(int *request_id,
			uint32_t combined_id, uint32_t flags,
			const gkt_voice_output_playback_attr_s *playback_attr);

int gkt_window_voice_play_multiple(int *request_id,
			const uint32_t *combined_ids, uint32_t combined_ids_num, 
			uint32_t flags);

void gkt_window_voice_play_common(uint32_t common_id);

int gkt_window_voice_play_meta(int *request_id,
			const gkt_voice_meta_id_t *meta_ids, 
			uint32_t meta_ids_num, uint32_t flags);

void gkt_window_voice_stop(uint32_t flags);
void gkt_window_voice_stop_id(int request_id);

void gkt_window_voice_set_mute(int mute_enable);

#else

#define gkt_window_voice_config(config_params)	do { } while(0)

#define gkt_window_voice_play(request_id, combined_id, \
			flags, playback_attr)	GKT_SUCCESS
#define gkt_window_voice_play_multiple(request_id, combined_ids, \
			combined_ids_num, flags)	GKT_SUCCESS
#define gkt_window_voice_play_common(common_id)	do { } while(0)

#define gkt_window_voice_stop(flags)	do { } while(0)
#endif

#ifdef __cplusplus
}
#endif

#endif	/* GKT_WINDOW_VOICE_H */

